package flc.ast.adapter;

import static android.view.View.GONE;
import static android.view.View.VISIBLE;

import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.stark.picselect.entity.SelectMediaEntity;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class ProPicAdapter extends StkProviderMultiAdapter<SelectMediaEntity> {

    public ProPicAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new ProPicProvider());
    }

    private class ProPicProvider extends BaseItemProvider<SelectMediaEntity> {
        @Override
        public int getItemViewType() {
            return SelPictureAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_pro_pic;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, SelectMediaEntity selectMediaEntity) {
            Glide.with(getContext()).load(selectMediaEntity.getPath())
                    .into((ImageView) baseViewHolder.getView(R.id.ivProPicItemImg));
            if (selectMediaEntity.isChecked()) {
                baseViewHolder.getView(R.id.ivProPicItemSel).setVisibility(VISIBLE);
            } else {
                baseViewHolder.getView(R.id.ivProPicItemSel).setVisibility(GONE);
            }
        }
    }

}
